package projet.bd;

import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.widget.Toast;

public class AlarmeService extends Service {
	 
	   @Override
	   public void onCreate() {
	      Toast.makeText(this, "Creation du service", Toast.LENGTH_LONG).show();
	   }
	 
	   @Override
	   public IBinder onBind(Intent intent) {
	   return null;
	   }
	 
	   @Override
	   public void onDestroy() {
	   super.onDestroy();
	   Toast.makeText(this, "Destruction du service", Toast.LENGTH_LONG).show();
	   }
	 
	   @Override
	   public void onStart(Intent intent, int startId) {
	      super.onStart(intent, startId);
	      Bundle extras = intent.getExtras();
	      String data = extras.getString("nel.example.alarme");
	      Toast.makeText(this, "Demarrage data = " + data,
	                            Toast.LENGTH_LONG).show();
	 
	      Intent alertIntent = new Intent();
	      alertIntent.setClass( this , AlarmeAlerte.class );
	      alertIntent.putExtra("nel.example.alarme",data);
	      alertIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	      startActivity( alertIntent );
	   }
	}